//如果代理函数的时候，打印了函数的所有内容了，证明没有保护该函数
ffglobal = {};

//描述符检测，函数toString检测
!(() => {
    "use strict";
    const $toString = Function.toString;  //hook Function.toString 且命名为myToString
    //变量名取随机数防检测
    const myFunction_toString_symbol = Symbol('('.concat('', ')_', (Math.random() + '').toString(36)));
    const myToString = function () {
        return typeof this == 'function' && this[myFunction_toString_symbol] || $toString.call(this);   //谁调用这个方法,this就是谁,比如boda调用,这个this就是boda
    };

    function set_native(func, key, value) {
        //定义描述符
        Object.defineProperty(func, key, {
            "enumerable": false,
            "configurable": true,
            "writable": true,
            "value": value
        })
    };
    delete Function.prototype['toString']; //删除原型链上的toString
    set_native(Function.prototype, "toString", myToString); //自己定义个getter方法
    //myToString的 myFunction_toString_symbol属性设置为  function toString() { [native code] }
    //myFunction_toString_symbol= function toString() { [native code] }
    set_native(Function.prototype.toString, myFunction_toString_symbol, "function toString() { [native code] }"); //套个娃 保护一下我们定义的toString 否则就暴露了
    ffglobal.safefunction = (func, name) => {
        set_native(func, myFunction_toString_symbol, `function ${myFunction_toString_symbol, name || ''}() { [native code] }`);
        set_native(func, 'name', `${myFunction_toString_symbol, name || ''}`);
        // }
    }; //导出函数到globalThis
}).call(this);
//对象标识符检测
ffglobal.reNameObj = function reNameObj(obj, obname) {
    Object.defineProperty(obj.prototype, Symbol.toStringTag, {
        value: obname,
        configurable: true,
        writable: false,
        enumerable: false
    })
};

/////============================
window = globalThis;
delete global;
delete Buffer;
// delete process;
delete __dirname;
delete __filename;

const FF_DEBUG_LOG = true; // 控制开关，false 就不打印
globalThis.dconsole = {
    log: function (...args) {
        if (FF_DEBUG_LOG)
            console.log(...args);
    }
};
Object.assign(window, {
    outerHeight: 901,
    outerWidth: 1412,
    // chrome: {},
    // setTimeout: function () {
    // },
    // setInterval: function () {
    // },
    name:'wqtqDdIAvlWspo90jgTEaqmWdXvopv2r04LicfLTFNJ+jk3KEdSXAVLh7SisyhmnbpZ253/8LNirgDy1XPBRFq9xEH3x75P2pqggUna3gIM=',
})
window._fmOpt = {
    partner: "popmart",
    appName: "popmart_web",
    token: "popmart_test-" + new Date().getTime() + "-" + Math.random().toString(16).substr(2),
    interfaceProtection: !0,
    timeout: 5e3,
    success: function (t) {
        window.blackbox = t;
        console.log("blackbox::::", t)
    }
};
window.RegExp=function (arg) {
    dconsole.log("RegExp:::", arg)
    if (arg=="(WebView|(iPhone|iPod|iPad)(?!.*Safari/)|Android.*(wv|.0.0.0))"){
        return "/(WebView|(iPhone|iPod|iPad)(?!.*Safari\\/)|Android.*(wv|.0.0.0))/"
    }
};ffglobal.safefunction(window.RegExp)
window.RTCPeerConnection=function (arg) {
    dconsole.log("RTCPeerConnection:::", arg)
};ffglobal.safefunction(window.RTCPeerConnection)
window.WebAssembly={}
window.WebAssembly.instantiate=function(arg){
    dconsole.log("WebAssembly.instantiate:::", arg)
};ffglobal.safefunction(window.WebAssembly.instantiate)
window.WebAssembly.compile=function(arg){
    dconsole.log("WebAssembly.compile:::", arg)
};ffglobal.safefunction(window.WebAssembly.compile)
window._TDWSC01FFEFAF1007014E=1;

window.chrome=function (arg) {
    dconsole.log("chrome:::", arg)
};ffglobal.safefunction(window.chrome)
Object.defineProperty(window.RTCPeerConnection.prototype, Symbol.toStringTag, {
    value:'RTCPeerConnection',
});ffglobal.safefunction(window.RTCPeerConnection);
window.RTCPeerConnection.prototype.createOffer=function (arg) {
    dconsole.log("RTCPeerConnection.createOffer:::", arg)
};ffglobal.safefunction(window.RTCPeerConnection.prototype.createOffer);
window.RTCPeerConnection.prototype.createDataChannel=function (arg) {
    dconsole.log("RTCPeerConnection.createDataChannel:::", arg)
};ffglobal.safefunction(window.RTCPeerConnection.prototype.createDataChannel);
window.webkitRTCPeerConnection = function (arg) {
    dconsole.log("webkitRTCPeerConnection:::", arg)
};ffglobal.safefunction(window.webkitRTCPeerConnection)
_storage= {};
window.addEventListener = function (arg) {
    dconsole.log("addEventListener:::", arg)
    if (arg=="storage"){
        return _storage;
    }
};ffglobal.safefunction(window.addEventListener)
document = {};
_trackfp={};
document.addEventListener=function (arg){
    dconsole.log('document中的addEventListener的参数为==>',arg)
    if (arg=="track-fp"){
        return _trackfp;
    }
};
window.mozRTCPeerConnection=undefined;
document.currentScript=null;
// _body = {};
// _body.childElementCount = 29
// _head = {};
// _head.childElementCount = 41;
// _2d = {};
// _2d.fillRect = function (arg) {
//     dconsole.log('2d中的fillRect的参数为==>', arg);
// };
// ffglobal.safefunction(_2d.fillRect, 'fillRect');
// _2d.arc = function (arg) {
//     dconsole.log('2d中的arc的参数为==>', arg);
//     return 50;
// };
// ffglobal.safefunction(_2d.arc, 'arc');
// _2d.stroke = function (arg) {
//     dconsole.log('2d中的stroke的参数为==>', arg);
// };
// ffglobal.safefunction(_2d.stroke, 'stroke');
// _2d.fillText = function (arg) {
//     dconsole.log('2d中的fillText的参数为==>', arg);
// };
// ffglobal.safefunction(_2d.fillText, 'fillText');
// _canvas = {};
// _canvas.getContext = function (arg) {
//     dconsole.log('canvas中的getContext的参数为==>', arg);
//     if (arg == '2d') {
//         return _2d;
//     }
// };
// ffglobal.safefunction(_canvas.getContext, 'getContext');
// _canvas.toDataURL = function (arg) {
//     dconsole.log('canvas中的toDataURL的参数为==>', arg);
//     return "";
// };
// ffglobal.safefunction(_canvas.toDataURL, 'toDataURL');
// document.cookie = 'o2State={%22webp%22:true%2C%22avif%22:true}; __jdu=1751545604909534518369; pinId=briEibRb-h1YgxkG81uaz7V9-x-f3wj7; pin=jd_7eac037a858fc; unick=jd_8js7q5tn2s7n2h; _tp=aO5XtogPiplRTZPyN6P5Vkd5JC%2FQJe7kEmh0g0oTaNI%3D; shshshfpa=ab96e4b0-82d6-a907-9206-6c096fe807bb-1751545628; shshshfpx=ab96e4b0-82d6-a907-9206-6c096fe807bb-1751545628; mt_xid=V2_52007VwMUVl1cV14YSBxUBG8HEFdZWFtYGEEpXVBjCkcCCAhOWBsdGUAAZQAUTg1eVFMDHhoLDDdQEQBeXFBdL0oYXwF7AhROXVhDWhlCHFQOZwMiUG1YYlMfSB1eBmMEFFJcX1ZZGk4RWQ1XAxFRXw%3D%3D; areaId=19; ipLoc-djd=19-1607-4773-62123; TrackID=1oewTDv6eVflY_HJgkzuOTgmL_p-6JTPedCSo2I6Yy9OP7jfY6j_peKkFgRgw_yDoqoH1X4N6DllRX6TMyXVIr08DQYKqcjsiluMfFrdiN_uVhlZAsFX03PfWDdQl1ekr; 3AB9D23F7A4B3C9B=GNWKXUTIE6HBK6NALGSXSPDIJB4FOSTK2HH5HNAWZAUUMF5JYQCGOIB4252C7TECGDOSXSGLUC74Z5SQVPIKNU2LBE; __jda=76161171.1751545604909534518369.1751545604.1752832750.1753068550.13; __jdc=76161171; __jdv=76161171|direct|-|none|-|1753068549992; PCSYCityID=CN_440000_440300_0; UseCorpPin=jd_7eac037a858fc; 3AB9D23F7A4B3CSS=jdd03GNWKXUTIE6HBK6NALGSXSPDIJB4FOSTK2HH5HNAWZAUUMF5JYQCGOIB4252C7TECGDOSXSGLUC74Z5SQVPIKNU2LBEAAAAMYFMK6VIIAAAAAC7DFGFTMGATUJ4X; mail_times=2%2C2; sdtoken=AAbEsBpEIOVjqTAKCQtvQu17W40wBwWdzIcSHNPr9NfRKXz-0XOL1ZcnZfZGYSQPo0Gpu8E78NBQ92nwAEZV9r3vxF-OZtsog7f32rnjJ_Kh3mFBmAEV_lHvBZCKDkQA2Q; shshshfpb=BApXSypISKP1AYEqgcJFHsyDPBX7ULrZhBhMVUQdu9xJ1MppMe462; __jdb=76161171.6.1751545604909534518369|13.1753068550';
// document.body = _body;
// document.head = _head;
// document.all = {
//     [Symbol.toStringTag]: "HTMLCollection",
// }
// _documentElement = {}
// document.documentElement = _documentElement
location={
    "ancestorOrigins": {},
    "href": "https://www.popmart.com/us/search/HA?page=5",
    "origin": "https://www.popmart.com",
    "protocol": "https:",
    "host": "www.popmart.com",
    "hostname": "www.popmart.com",
    "port": "",
    "pathname": "/us/search/HA",
    "search": "?page=5",
    "hash": ""
}
navigator = {
    appCodeName: "Mozilla",
    appName: "Netscape",
    appVersion: "5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36",
    cookieEnabled: true,
    doNotTrack: null,
    hardwareConcurrency: 12,
    language: "zh-CN",
    languages: ["zh-CN", "zh"],
    maxTouchPoints: 0,
    onLine: true,
    pdfViewerEnabled: true,
    platform: "Win32",
    plugins: {
        length: 4,
        [Symbol.toStringTag]: 'PluginArray',
        0: {
            name: 'PDF Viewer',
            [Symbol.toStringTag]: 'Plugin',
            length: 2
        },
        1: {
            name: 'ff_ss',
            [Symbol.toStringTag]: 'Plugin',
            length: 2
        },
        2: {
            name: 'ss_ff',
            [Symbol.toStringTag]: 'Plugin',
            length: 2
        },
        3: {
            name: 'FFloveSS',
            [Symbol.toStringTag]: 'Plugin',
            length: 2
        },
    },
    product: "Gecko",
    productSub: "20030107",
    userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0',
    vendor: "Google Inc.",
    vendorSub: "",
    webdriver: false,
    mimeTypes: {
        length: 2,
        [Symbol.toStringTag]: 'MimeTypeArray',
        0: {
            description: "Portable Document Format",
            [Symbol.toStringTag]: 'Plugin',
            length: 2,
            suffixes: "pdf",
            type: "application/pdf",
        },
        1: {
            description: "Portable Document Format",
            [Symbol.toStringTag]: 'Plugin',
            length: 2,
            suffixes: "pdf",
            type: "text/pdf",
        },

    },
    userAgentData: {
        [Symbol.toStringTag]: 'NavigatorUAData',
        "brands": [
            {
                "brand": "Not)A;Brand",
                "version": "8"
            },
            {
                "brand": "Chromium",
                "version": "138"
            },
            {
                "brand": "Microsoft Edge",
                "version": "138"
            }
        ],
        "mobile": false,
        "platform": "Windows"
    }
};
history = {};
screen = {
    availHeight: 901,
    availLeft: 0,
    availTop: 0,
    availWidth: 1412,
    colorDepth: 24,
    height: 942,
    pixelDepth: 24,
    width: 1412,
};
localStorage = {};
localStorage.getItem=function (val) {
    dconsole.log("localStorage.getItem==>", val)
    if (val=="E0701BBE33D9FD0A"){
        return 'zRNGW5u4M1752217249213OauAaWi1592e'
    }
    if (val=="_xid"){
        return null
    }
    if (val=="c"){
        return null
    }
    if (val=="62BB9B5EB31B00B0"){
        return 'wqtqDdIAvlWspo90jgTEaqmWdXvopv2r04LicfLTFNJ+jk3KEdSXAVLh7SisyhmnbpZ253/8LNirgDy1XPBRFq9xEH3x75P2pqggUna3gIM='
    }
}
localStorage.setItem=function (key,val) {
    dconsole.log("localStorage.setItem==>", key,val)
}
sessionStorage = {};
sessionStorage.getItem=function (val) {
    dconsole.log("sessionStorage.getItem==>", val)
    if (val=="_xid"){
        return null;
    }
    if (val=="62BB9B5EB31B00B0"){
        return 'wqtqDdIAvlWspo90jgTEaqmWdXvopv2r04LicfLTFNJ+jk3KEdSXAVLh7SisyhmnbpZ253/8LNirgDy1XPBRFq9xEH3x75P2pqggUna3gIM='
    }
    if (val=="E0701BBE33D9FD0A"){
        return 'zRNGW5u4M1752217249213OauAaWi1592e'
    }
}
sessionStorage.setItem=function (key,val) {
    dconsole.log("sessionStorage.setItem==>", key,val)
}
// _script.src = ""

/////============================
//里面全是函数
/////=========函数集合地===================
//window==========================================================================================================

// window.addEventListener = function addEventListener(arg) {
//     // if (arg === 'load') {
//     //     return {}
//     // }
//     dconsole.log('window中的addEventListener的参数为==>', arg);
//     debugger;
// };
// ffglobal.safefunction(window.addEventListener, 'addEventListener');

//document==========================================================================================================
// document.querySelector = function querySelector(arg) {
//     dconsole.log('document中的querySelector的参数为==>', arg);
// };
// ffglobal.safefunction(document.querySelector, 'querySelector');
// document.createEvent = function createEvent(arg) {
//     dconsole.log('document中的createEvent的参数为==>', arg);
//     debugger;
// };
// ffglobal.safefunction(document.createEvent, 'createEvent');
//
_script = {};
document.createElement = function createElement(arg) {
    // if (arg === "canvas") {
    //     return _canvas
    // }
    if (arg === "script") {
        return _script
    }
    dconsole.log('document中的createElement的参数为==>', arg);
    debugger;
};
ffglobal.safefunction(document.createElement, 'createElement');
// _getElementsByTagName_head = {
//     0: {
//         appendChild: function appendChild(arg) {
//             dconsole.log('_getElementsByTagName_head中的appendChild的参数为==>', arg);
//             debugger;
//         }
//     }
// }
_dscript={
    0: {
        parentNode: {
            insertBefore: function insertBefore(arg) {
                dconsole.log('_dscript中的insertBefore的参数为==>', arg);
                debugger;
            }
        }
    }
};
document.getElementsByTagName = function getElementsByTagName(arg) {
    // if (arg == "head") {
    //     return _getElementsByTagName_head
    // }
    // if (arg === 'meta') {
    //     return [
    //         {}, {
    //             content: content,
    //             parentNode: {
    //                 removeChild: function () { }
    //             },
    //             getAttribute: function () { }

    //         }
    //     ]
    // }
    if (arg === 'script') {
        return _dscript
    }
    // if (arg === "base") {
    //     return {
    //         length: 0
    //     }
    // }
    dconsole.log('document中的getElementsByTagName的参数为==>', arg);
    debugger;
};
ffglobal.safefunction(document.getElementsByTagName, 'getElementsByTagName');
// document.addEventListener = function addEventListener(arg) {
//     dconsole.log('document中的addEventListener的参数为==>', arg);
//     debugger;
// };
// ffglobal.safefunction(document.addEventListener, 'addEventListener')
// document.removeChild = function (arg) {
//     dconsole.log('document中的removeChild的参数为==>', arg);
//     debugger;
// };
// ffglobal.safefunction(document.removeChild, 'removeChild')
// document.getElementById = function (arg) {
//     dconsole.log('document中的getElementById的参数为==>', arg);
//     debugger;
// };
// ffglobal.safefunction(document.getElementById, 'getElementById')
//
// //localStorage==========================================================================================================
//
// localStorage.getItem = function getItem(arg) {
//     dconsole.log('localStorage中的getItem的参数为==>', arg);
//     debugger;
// };
// ffglobal.safefunction(localStorage.getItem, 'getItem');
// localStorage.setItem = function setItem(key, val) {
//     dconsole.log('localStorage中的setItem的参数为==>', key, val);
//     debugger;
// };
// ffglobal.safefunction(localStorage.setItem, 'setItem');
//==========================================================================================================

//===========代理===============
let count = 0;
let skipCount = 0; // 设置你想跳过的打印次数

// 忽略不打印属性
let ignoreList = ["Date"];

// 原生构造器集合，遇到这里面直接返回，不 proxy
const nativeCtorNameSet = new Set([
    // "Date", "Function", "Object", "Array", "Error", "String", "Number",
    // "Boolean", "Symbol", "Map", "Set", "WeakMap", "WeakSet", "Promise", "BigInt",
    // "Proxy", "Reflect", "Intl"
]);

function proxy(obj, objName) {
    // 本体是原生构造器直接返回
    if (
        typeof obj === 'function'
        && nativeCtorNameSet.has(obj.name)
    ) {
        return obj;
    }
    // 对于如 null/undefined/基础类型，也直接返回本体
    if (obj === null || obj === undefined || typeof obj !== 'object' && typeof obj !== 'function') {
        return obj;
    }

    let printedProps = new Set();
    let handler = {
        get(target, prop, receiver) {
            // prototype/name/length 这三种直接透传，绝不代理
            if (prop === 'prototype' || prop === 'name' || prop === 'length') {
                return Reflect.get(target, prop, receiver);
            }
            if (ignoreList.includes(prop)) {
                return Reflect.get(target, prop, receiver);
            }
            // 属性没打印过则处理（为防递归死环/重复打印）
            if (!printedProps.has(prop)) {
                let result = Reflect.get(target, prop, receiver);
                count++;
                if (typeof result === 'function') {
                    if (result.toString().length <= 60) {
                        if (skipCount > 0) { skipCount--; }
                        else dconsole.log('计数:', count, `[${objName}]`, '获取属性', prop, '[FF函数经过]=>', result.toString());
                    } else {
                        if (skipCount > 0) { skipCount--; }
                        else dconsole.log('计数:', count, `[${objName}]`, '获取属性(===toString值太长===):', prop);
                    }
                    // 非原生构造器时才能递归代理
                    if (
                        typeof result === 'function' &&
                        !nativeCtorNameSet.has(result.name)
                    ) {
                        result = proxy(result, objName + '.' + prop);
                    }
                } else if (typeof result === "object" && result !== null) {
                    if (result.toString().length <= 60) {
                        if (skipCount > 0) { skipCount--; }
                        else dconsole.log('计数:', count, `[${objName}]`, '获取属性', prop, '[OO对象经过]=>', result.toString());
                    } else {
                        if (skipCount > 0) { skipCount--; }
                        else dconsole.log('计数:', count, `[${objName}]`, '获取属性(===toString值太长===):', prop);
                    }
                    result = proxy(result, objName + '.' + prop);
                } else {
                    if (skipCount > 0) { skipCount--; }
                    else dconsole.log('计数:', count, `[${objName}]`, '获取属性', prop, '[值为]=>', result);
                }
                printedProps.add(prop);
                return result;
            }
            return Reflect.get(target, prop, receiver);
        },
        set(target, propKey, value, receiver) {
            if (propKey === 'prototype' || propKey === 'name' || propKey === 'length') {
                return Reflect.set(target, propKey, value, receiver);
            }
            if (ignoreList.includes(propKey)) {
                return Reflect.set(target, propKey, value, receiver);
            }
            if (!printedProps.has(propKey)) {
                count++;
                if (typeof value === 'function') {
                    if (value.toString().length <= 60) {
                        if (skipCount > 0) { skipCount--; }
                        else dconsole.log('计数:', count, `[${objName}]`, '设置属性:', propKey, 'value:', value.toString());
                    } else {
                        if (skipCount > 0) { skipCount--; }
                        else dconsole.log('计数:', count, `[${objName}]`, '设置属性(===toString值太长===):', propKey);
                    }
                } else {
                    if (skipCount > 0) { skipCount--; }
                    else dconsole.log('计数:', count, `[${objName}]`, '设置属性:', propKey, 'value:', value);
                }
                printedProps.add(propKey);
            }
            return Reflect.set(target, propKey, value, receiver);
        }
    };
    return new Proxy(obj, handler);
}
/////=========构造函数============
Window = function Window() {
};
ffglobal.reNameObj(Window, 'Window');
Document = function Document() {
};
ffglobal.reNameObj(Document, 'Document');
HTMLDocument = function HTMLDocument() {
};
ffglobal.reNameObj(HTMLDocument, 'HTMLDocument');
Location = function Location() {
};
ffglobal.reNameObj(Location, 'Location');
History = function History() {
};
ffglobal.reNameObj(History, 'History');
Navigator = function Navigator() {
};
ffglobal.reNameObj(Navigator, 'Navigator');
Screen = function Screen() {
};
ffglobal.reNameObj(Screen, 'Screen');
Storage = function Storage() {
};
ffglobal.reNameObj(Storage, 'Storage');
Node = function Node() {
};
ffglobal.reNameObj(Node, 'Node');
Element = function Element() {
};
ffglobal.reNameObj(Element, 'Element');
window.HTMLElement = function HTMLElement(arg) {
    dconsole.log("window.HTMLElement:::", arg)
};
ffglobal.reNameObj(window.HTMLElement, 'HTMLElement');
////================原型绑定================///////
window.__proto__ = Window.prototype;
document.__proto__ = HTMLDocument.prototype;
HTMLDocument.prototype.__proto__ = Document.prototype;
Element.prototype.__proto__ = Node.prototype;
location.__proto__ = Location.prototype;
history.__proto__ = History.prototype;
navigator.__proto__ = Navigator.prototype;
screen.__proto__ = Screen.prototype;
localStorage.__proto__ = Storage.prototype;
sessionStorage.__proto__ = Storage.prototype;
window.HTMLElement.prototype.__proto__==Element.prototype
/////===================代理对象=====================//////
window = proxy(window, 'window')
document = proxy(document, 'document')
navigator = proxy(navigator, 'navigator')
location = proxy(location, 'location')
history = proxy(history, 'history')
screen = proxy(screen, 'screen')
localStorage = proxy(localStorage, 'localStorage')
sessionStorage = proxy(sessionStorage, 'sessionStorage')
_storage = proxy(_storage, '_storage')
_trackfp = proxy(_trackfp, '_trackfp')
window.WebAssembly = proxy(window.WebAssembly, 'WebAssembly')
// _body = proxy(_body, '_body')
// _head = proxy(_head, '_head')
// _canvas = proxy(_canvas, '_canvas')
// _2d = proxy(_2d, '_2d')
// _documentElement = proxy(_documentElement, '_documentElement')
// _crypto = proxy(_crypto, '_crypto')
_script = proxy(_script, '_script')
_dscript = proxy(_dscript, '_dscript')
// _getElementsByTagName_head = proxy(_getElementsByTagName_head, '_getElementsByTagName_head')
// document.all = proxy(document.all, 'document.all')//